new Vue({
    el: '#app',
    data() {
        return {
            form: {
                Start_Date: '',
                End_Date: '',
                Article_Name: '',
                Supplier_SerialNumber: '',
                Enterprise_Info_SerialNumber:$.cookie('enterprise'),
                Type:0,//类型
                page: 1,			//页数
                limit: 10,		//每页数据条数
            },
            total: 0,// 总条数
            supplier: [],
            tableData: [],
            Data:{
                Purchase_Amount:0,
                Paid_Amount:0
            },
            loading: false,//节流
            pickerOptions: pickerOptionsTwo,
            time: null,

        }
    },
    mounted() {
        this.form.End_Date = getYMDHMSDate();
        this.form.Start_Date  = getYMDHMSDate(new Date().getTime() - 30 * 24 * 60 * 60 * 1000);
        this.time = [this.form.Start_Date, this.form.End_Date]
        this.getList(this.form);
        this.getData()
    },
    computed: {
        //去.0
        ZeroRemoval() {
            return function (params) {
                params = params.replace('.0', '')
                return params
            }
        },
        //千分位处理
        thousands() {
            return function (params) {
                params = Number(params).toFixed(2)
                return params.replace(/\B(?=(\d{3})+(?!\d))/g, ',');
            }
        },
        //百分比处理
        toPercent() {
            return function (point) {
                point = Number(point * 100).toFixed(2);
                return point += "%";
            }
        },
    },
    methods: {
        getList(data){
            console.log(data);
            $.ajax({
                type: 'POST',
                url: `${DomainName}/getPurchaseReport1Action?token=${$.cookie('token')}`,
                data,
                success: (res) => {
                    console.log(res);
                    this.Data= res.Data
                    this.tableData = res.tableData
                    this.total = res.limit
                },
                complete: (XMLHttpRequest) => {
                    this.loading = false
                    if (XMLHttpRequest.getResponseHeader("REDIRECT") == "REDIRECT") {
                        window.parent.document.location.href = absolutepath() + XMLHttpRequest.getResponseHeader("CONTENTPATH");
                    }
                },
                dataType: "json"
            });
        },
        getData(){
            $.ajax({
                type: 'POST',
                url: `${DomainName}/getInquiryAction?token=${$.cookie('token')}`,
                data:{
                    Data:'supplier_info'
                },
                success: (res) => {
                    this.supplier = res
                },
                complete: (XMLHttpRequest) => {
                    if (XMLHttpRequest.getResponseHeader("REDIRECT") == "REDIRECT") {
                        window.parent.document.location.href = absolutepath() + XMLHttpRequest.getResponseHeader("CONTENTPATH");
                    }
                },
                dataType: "json"
            });
        },
        handleclassify() {//分类查询
            this.page = 1;
            this.getList(this.form);
        },
        DateChange() {
            this.page = 1;
            if (this.time != null) {
                this.form.Start_Date = this.time[0]
                this.form.End_Date = this.time[1]
            } else {
                this.form.Start_Date = ''
                this.form.End_Date = ''
            }
            this.getList(this.form);
        },       
        handleSizeChange(val) {//分页查询
            this.form.page = 1;
            this.form.limit = val;
            this.getList(this.form)
        },
        handleCurrentChange(val) {
            this.form.page = val;
            this.getList(this.form)
        },
    },
})